<?php

namespace App\Console\Commands\Controller;

use App\Console\BaseCommand;
use App\Models\UserMessageCount;

class MessageCountCommand extends BaseCommand
{
    protected $signature = 'controller:message-count {action} {json}';

    protected $description = 'message count commands';

    public function clean($data)
    {
        $query = UserMessageCount::getInstance($data['user_id'])
            ->where('user_id', $data['user_id']);
        if (isset($data['message_type']) && $data['message_type'] >= 0) {
            $query->where('message_type', $data['message_type']);
        }

        $query->update(['count' => 0]);

        return true;
    }
}
